<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2019/2/22
 * Time: 16:01
 */

namespace app\login\controller;


use app\api\service\Token;
use app\login\service\StatisticsService;
use app\login\validate\Statistics as StatisticsValidate;

class Statistics extends BaseController
{
    public function index()
    {
        return $this->fetch('/login/statistics');
    }
    # 获取一个月内所有的流量记录或者注册的记录
    public function getMonthData($time, $model)
    {
        (new StatisticsValidate()) -> goCheck();
        $from = Token::getRedisTokenName();
        $service = new StatisticsService();
        $result = $service->monthData($from, $time, $model);
        return json($result);
    }
    # 获取每个标识码一周内的注册量
    public function getSignWeek($time, $model)
    {
        (new StatisticsValidate()) -> goCheck();
        $from = Token::getRedisTokenName();
        $service = new StatisticsService();
        $result = $service->weekSign($from, $time, $model);
        return json([
            'code' => 0,
            'data' => $result
        ]);
    }
}